<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // console.log(1);
    // var p = new Promise(function (resolve, reject) {
    //     console.log(2);
    //     setTimeout(function () {
    //         resolve(3);
    //     }, 2000)
    // })

    // p.then(function (arg) {
    //     console.log(arg);
    // })

    // console.log(4);

    // 注意: Promise.prototype.then() Promise.prototype.catch() 也属于异步任务, 等所有同步代码执行完毕,且Promise对象状态改变之后 -> 才会将回调函数放到主线程执行

    console.log(1);
    var p = new Promise(function (resolve, reject) {
        console.log(2);
        resolve(3);
    })// {fulfilled:3}
    console.log(p);
    p.then(function (arg) {
        console.log(arg);
    })

    console.log(4);







</script>

</html>